import java.util.ArrayList;
import java.util.List;

public class problem43 {
    public static void main(String[] args) {
        List<Long> numbers = new ArrayList<Long>();
        for(Long number : ProjectEuler.getPandigitals(1023456789L)) {
            String numberString = number.toString();
            if(numberString.length() == 10 &&
               Long.valueOf(numberString.substring(1, 4)) % 2 == 0 &&
               Long.valueOf(numberString.substring(2, 5)) % 3 == 0 &&
               Long.valueOf(numberString.substring(3, 6)) % 5 == 0 &&
               Long.valueOf(numberString.substring(4, 7)) % 7 == 0 &&
               Long.valueOf(numberString.substring(5, 8)) % 11 == 0 &&
               Long.valueOf(numberString.substring(6, 9)) % 13 == 0 &&
               Long.valueOf(numberString.substring(7, 10)) % 17 == 0)
                numbers.add(number);
        }

        Long sum = 0L;
        for(Long number : numbers)
            sum += number;
        System.out.println(sum);
    }
}
